package com.chenchen.code.guava.io;

import com.google.common.io.ByteSource;
import com.google.common.io.Files;
import org.junit.Test;
import com.google.common.hash.Hashing;
import com.google.common.io.ByteSink;
import com.google.common.io.ByteSource;
import com.google.common.io.Files;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import java.io.IOException;

/**
 * @Description:
 * @author chenchen
 * @date 2019/5/13 10:49
 */
public class ByteSourceTest {

    private final String source = "D:\\guavatest\\source.txt";
    private final String target = "D:\\guavatest\\target.txt";

    @Test
    public void testAsByteSource() throws IOException {
        File file = new File(source);
        ByteSource byteSource = Files.asByteSource(file);
        byte[] readBytes = byteSource.read();
        assertThat(readBytes, is(Files.toByteArray(file)));
    }

}
